package com.atguigu.gmall.webcontroller;

import com.atguigu.gmall.entity.BaseCategoryView;
import com.atguigu.gmall.entity.ProductSalePropertyKey;
import com.atguigu.gmall.entity.SkuInfo;
import com.atguigu.gmall.service.BaseCategoryViewService;
import com.atguigu.gmall.service.SkuDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/sku/")
public class SkuDetailController {

    @Autowired
    private SkuDetailService skuDetailService;

    @Autowired
    private BaseCategoryViewService categoryViewService;

    @GetMapping("getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId){
        SkuInfo skuInfo = skuDetailService.getById(skuId);
        return skuInfo;
    }
    @GetMapping("getCategoryView/{category3Id}")
    public BaseCategoryView getCategoryView(@PathVariable Long category3Id){
        return categoryViewService.getById(category3Id);
    }
    //2.根据productId,skuId查询商品销售属性key与value
    @GetMapping("getSkuSalePropertyKeyAndValue/{productId}/{skuId}")
    public List<ProductSalePropertyKey> getSkuSalePropertyKeyAndValue(@PathVariable Long productId, @PathVariable Long skuId){
        return skuDetailService.getSkuSalePropertyKeyAndValue(productId,skuId);
    }

    @GetMapping("getSkuSalePropertyValueId/{productId}")
    public Map getSkuSalePropertyValueId(@PathVariable Long productId){
        return skuDetailService.getSkuSalePropertyValueId(productId);
    }

}


